<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg">
  <head>
    <title>Lexical and datum syntax</title>
    <link rel="stylesheet" type="text/css" href="docbook-epub.css"/>
    <link rel="stylesheet" type="text/css" href="kawa.css"/>
    <script src="kawa-ebook.js" type="text/javascript"/>
    <meta name="generator" content="DocBook XSL-NS Stylesheets V1.79.1"/>
    <link rel="prev" href="Syntax-notation.xhtml" title="Notation"/>
    <link rel="next" href="Lexical-syntax.xhtml" title="Lexical syntax"/>
  </head>
  <body>
    <header/>
    <section class="sect1" title="Lexical and datum syntax" epub:type="subchapter" id="Lexical-and-datum-syntax">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title" style="clear: both">Lexical and datum syntax</h2>
          </div>
        </div>
      </div>
      <p>The syntax of Scheme code is organized in three levels:
</p>
      <div class="orderedlist" epub:type="list">
        <ol class="orderedlist" type="1">
          <li class="listitem" epub:type="list-item">
            <p>the <span class="emphasis"><em>lexical syntax</em></span> that describes how a program text is split
into a sequence of lexemes,
</p>
          </li>
          <li class="listitem" epub:type="list-item">
            <p>the <span class="emphasis"><em>datum syntax</em></span>, formulated in terms of the lexical syntax, that
structures the lexeme sequence as a sequence of <span class="emphasis"><em>syntactic data</em></span>,
where a syntactic datum is a recursively structured entity,
</p>
          </li>
          <li class="listitem" epub:type="list-item">
            <p>the <span class="emphasis"><em>program syntax</em></span> formulated in terms of the datum syntax,
imposing further structure and assigning meaning to syntactic data.
</p>
          </li>
        </ol>
      </div>
      <p>Syntactic data (also called <span class="emphasis"><em>external representations</em></span>) double as a
notation for objects, and the <code class="literal">read</code> and
<code class="literal">write</code> procedures can be used for reading and writing syntactic data,
converting between their textual representation and the corresponding
objects.  Each syntactic datum represents a corresponding
<span class="emphasis"><em>datum value</em></span>.  A syntactic datum can be used in a program to obtain the
corresponding datum value using <code class="literal">quote</code>.

</p>
      <p>Scheme source code consists of syntactic data and (non–significant)
comments.  Syntactic data in Scheme source code are called <span class="emphasis"><em>forms</em></span>.
(A form nested inside another form is called a <span class="emphasis"><em>subform</em></span>.)
Consequently, Scheme’s syntax has the property that any sequence of
characters that is a form is also a syntactic datum representing some
object.  This can lead to confusion, since it may not be obvious out of
context whether a given sequence of characters is intended to be a
representation of objects or the text of a program.  It is also a source
of power, since it facilitates writing programs such as interpreters or
compilers that treat programs as objects (or vice versa).
</p>
      <p>A datum value may have several different external representations.  For
example, both <code class="literal">#e28.000</code> and <code class="literal">#x1c</code> are syntactic data
representing the exact integer object 28, and the syntactic data
<code class="literal">(8 13)</code>, <code class="literal">( 08 13 )</code>, <code class="literal">(8 . (13 . ()))</code> all represent a
list containing the exact integer objects 8 and 13.  Syntactic data that
represent equal objects (in the sense of <code class="literal">equal?</code>)
are always equivalent as forms of a program.
</p>
      <p>Because of the close correspondence between syntactic data and datum
values, we sometimes uses the term <span class="emphasis"><em>datum</em></span> for either a
syntactic datum or a datum value when the exact meaning is apparent from
the context.
</p>
    </section>
    <footer>
      <div class="navfooter">
        <p>
          Up: <a accesskey="u" href="Syntax.xhtml">Syntax</a></p>
        <p>
        Previous: <a accesskey="p" href="Syntax-notation.xhtml">Notation</a></p>
        <p>
        Next: <a accesskey="n" href="Lexical-syntax.xhtml">Lexical syntax</a></p>
      </div>
    </footer>
  </body>
</html>
